<template>
  <div class="container">
    <div style="background-color: #2758bb">
      <nav-bar subTitle="入链找链">
      </nav-bar>
    </div>
    <div class="body">
      <div class="find-card">
        <el-row :gutter="20">
          <el-col :span="8">
            <div class="find-title">入链企业前五行业</div>
            <ul class="find-ul">
              <li v-for="(item,index) in progressList">
                <div>
                  <span style="display: flex;align-items: end">
                    <template v-if="index <= 2">
                      <el-image :src="logoList[index]"/>
                    </template>
                    <template v-else>
                      <span class="find-index">{{ index + 1 }}</span>
                    </template>
                   <span style="margin-left: 5px"> {{ item.title }}</span>
                  </span>
                  <span>{{ item.count }}家</span>
                </div>
                <div class="find-progress">
                  <div class="find-progress-item" :style="setProgressWidth(item.count)"></div>
                </div>
              </li>
            </ul>
          </el-col>
          <el-col :span="8">
            <div class="find-title">入链找链概览</div>
            <ul class="find-mlg">
              <li v-for="(item,index) in linkProducts" @click="current = index">
                <el-image :src="index===current?linkLogos[0]:linkLogos[1]"></el-image>
                <div :style="{marginBottom: index===1?'80px':'20px',color:index===current?'#1052dc':''}">
                  <strong>{{ item.count }} </strong><small>{{ item.unit }}</small>
                  <br>
                  {{ item.title }}
                </div>
              </li>
            </ul>
          </el-col>
          <el-col :span="8">
            <div class="find-title">入链产品</div>
            <div class="find-pie">
              <chain-product-pie-chart :tableData="linkProducts[current]"></chain-product-pie-chart>
            </div>
          </el-col>
        </el-row>
      </div>
      <div class="find-card" style="height: auto">
        <el-row :gutter="20">
          <el-col :span="16">
            <ul class="find-list">
              <li v-for="(item,index) in detailedData" :class="detailCurrent === index ?'active':''"
                  @click="detailCurrent = index">
                <span>{{ item.title }}</span>
              </li>
            </ul>
            <ul class="find-data">
              <li>
                <div>{{ detailedData[detailCurrent].total.productNumber }}条</div>
                <div>入链产品数</div>
              </li>
              <li>
                <div>{{ detailedData[detailCurrent].total.demandNumber }}条</div>
                <div>入链需求数</div>
              </li>
              <li>
                <div>{{ detailedData[detailCurrent].total.companyNumber }}家</div>
                <div>入链产企业数</div>
              </li>
              <li>
                <div>{{ detailedData[detailCurrent].total.waitAuditProductNumber }}条</div>
                <div>待审核产品数</div>
              </li>
              <li>
                <div>{{ detailedData[detailCurrent].total.waitAuditDemandNumber }}条</div>
                <div>待审核需求数</div>
              </li>
              <li>
                <div>{{ detailedData[detailCurrent].total.waitAuditCompanyNumber }}条</div>
                <div>待审核企业信息</div>
              </li>
            </ul>
            <div style="height: 440px;background-color: #efefef">
              <demand-chart :tableData="detailedData[detailCurrent].detail"></demand-chart>
            </div>
          </el-col>
          <el-col :span="8">
            <div class="find-title">近半年入链产品态势感知</div>
            <div style="height: 300px">
              <product-situation-chart :tableData="halfYearData"></product-situation-chart>
            </div>
            <div class="find-title">近半年入链需求态势感知</div>
            <div style="height: 300px">
              <demand-situation-chart></demand-situation-chart>
            </div>
          </el-col>
        </el-row>
      </div>
    </div>
  </div>
</template>


<script setup>
import NavBar from "@/components/navBar.vue";
import {reactive, ref} from "vue";
import utils from "@/utils/index.js";
import ChainProductPieChart from "@/views/findChain/Echarts/ChainProductPieChart.vue";
import {detailedData, halfYearData, linkProducts, progressList} from "./data/data.js"
import DemandChart from "@/views/findChain/Echarts/DemandChart.vue";
import ProductSituationChart from "@/views/findChain/Echarts/ProductSituationChart.vue";
import DemandSituationChart from "@/views/findChain/Echarts/DemandSituationChart.vue";

const logoList = [
  utils.getAssetsFile('pai_1.png'),
  utils.getAssetsFile('pai_2.png'),
  utils.getAssetsFile('pai_3.png'),
]
const current = ref(0)
const detailCurrent = ref(0)

const setProgressWidth = (p) => {
  return {
    width: parseInt(parseInt(p) / parseInt(progressList[0].count) * 100) + '%'
  }
}

const linkLogos = reactive([
  utils.getAssetsFile('mid1.png'),
  utils.getAssetsFile('mid2.png')
])


</script>

<style scoped lang="scss">
.container {
  background-color: #ecf1f7;
}

.body {
  box-sizing: border-box;
  padding: 15px;
  background-image: url('@/assets/images/gover_home_bg.png');
  background-repeat: no-repeat;
  background-size: cover;
  background-position: top;
  background-color: #ecf1f7;
}

.find-card {
  width: 1200px;
  height: 380px;
  margin: 30px auto;
  border-radius: 3px;
  background-color: #ffffff;
  padding: 20px 30px;
  box-sizing: border-box;
  box-shadow: 0 0 10px 0 rgba(0, 0, 0, 0.1);
}

.find-title {
  position: relative;
  display: inline-block;
  font-size: 16px;
  font-weight: bold;
  height: 30px;
  line-height: 30px;

  &::after {
    content: '';
    position: absolute;
    top: 8px;
    right: -25px;
    width: 18px;
    height: 14px;
    background-image: url("");
    background-repeat: no-repeat;
    background-size: cover;
    background-position: center;
  }
}

.find-ul {
  padding: 15px 10px;

  > li {
    > div {
      font-size: 14px;
      display: flex;
      justify-content: space-between;
      align-items: center;
      margin-bottom: 8px;

      .find-index {
        font-size: 12px;
        width: 20px;
        height: 20px;
        line-height: 20px;
        text-align: center;
        background-color: #e4e4e4;
        border-radius: 50%;
        margin-right: 5px;
        display: inline-block
      }
    }

    height: 50px;
    margin-bottom: 10px;
  }
}

.find-progress {
  width: 100%;
  height: 10px;
  border-radius: 5px;
  background-color: #efefef;

  .find-progress-item {
    border-radius: 5px;
    height: 10px;
    background: linear-gradient(to right, #26e9e9, #6391f0);
    position: relative;

    &::after {
      content: '';
      position: absolute;
      right: -5px;
      top: -5px;
      width: 20px;
      height: 20px;
      background-image: url('@/assets/images/pro-fix.png');
      background-repeat: no-repeat;
      background-size: cover;
      background-position: center;
    }
  }
}

.find-mlg {
  width: 100%;
  height: 280px;
  background-image: url('@/assets/images/midBg.png');
  background-repeat: no-repeat;
  background-size: 100% 80%;
  background-position: bottom;
  display: flex;
  font-size: 14px;

  > li {
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    justify-content: end;
  }
}

.find-pie {
  width: 100%;
  height: 290px;
  box-sizing: border-box;
}

.find-list {
  display: flex;

  > li {
    cursor: pointer;
    font-size: 12px;
    width: 95px;
    height: 50px;
    padding: 6px 20px;
    box-sizing: border-box;
    border: 1px solid #efefef;
    margin-right: 5px;
    display: flex;
    align-items: center;
    transition: .15s;

    &:last-child {
      margin-right: 0;
    }

    > span {
      display: -webkit-box;
      -webkit-line-clamp: 2;
      -webkit-box-orient: vertical;
      overflow: hidden;
      text-overflow: ellipsis;
    }
  }

  .active {
    color: #ffffff;
    background: linear-gradient(to right, #1153dd, #248bf0);
    position: relative;

    &::after {
      content: '◢';
      position: absolute;
      left: calc(50% - 7px);
      top: 34px;
      font-size: 20px;
      color: #1153dd;
      transform: rotate(45deg);
    }
  }
}

.find-data {
  margin-top: 20px;
  background-color: #f2f7ff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px;
  margin-bottom: 20px;

  > li {
    font-size: 14px;

    > div:first-child {
      font-weight: bold;
    }
  }

  > li:last-child {
    margin-right: 0;
  }
}
</style>
